package cn.edu.javaweb.service;

import java.util.*;
import java.util.List;

import cn.edu.javaweb.javabean.Page;

public class AdminePageService {
	public Page getPage(String str,int page,List list){
		Page p=new Page();
		try {
            //当前页数
            page = Integer.valueOf(str);
        } catch (NumberFormatException e) {
            page = 1;
        }
		int tolist= list.size();
        int perpage = 4;
        int toall = tolist % perpage == 0 ? tolist / perpage : tolist / perpage + 1;
        int beginIndex = (page - 1) * perpage;
        int endIndex = beginIndex + perpage;
        if (endIndex > tolist)
            endIndex = tolist;
		p.setBeginIndex(beginIndex);;
		p.setEndIndex(endIndex);
		p.setPage(page);
		p.setToall(toall);
		return p;
	}

	
}
